package cn.niit.smbms.service.impl;

import cn.niit.smbms.dao.NewsMapper;
import cn.niit.smbms.entity.News;
import cn.niit.smbms.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author xiaomi
 */
@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsMapper newsMapper;

    /**
     * 查询新闻列表
     *
     * @param news
     * @return
     */
    @Override
    public List<News> selectNewsList(News news) {
        return newsMapper.selectListByNews(news);
    }

    /**
     * 插入新闻记录
     *
     * @param news
     */
    @Override
    public int insertNews(News news) {
        news.setPubtime(new Date());
        news.setDelFlag(0);
        return newsMapper.insertNews(news);
    }

    /**
     * 更新新闻记录
     *
     * @param news
     */
    @Override
    public int updateNews(News news) {
        news.setPubtime(new Date());
        return newsMapper.updateNews(news);
    }

    /**
     * 删除新闻记录
     *
     * @param newsId
     */
    @Override
    public int deleteNews(Long newsId) {
        return newsMapper.deleteNews(newsId);
    }
}
